<!--# layout("/common/layout.html",{"jsBase":"/js/spread/channelSet/"}){ -->

<form class="layui-form layui-form-pane" id="addForm"  lay-filter="editform">
    <input type="hidden" name="tenantId">
    <input type="hidden" name="choicePrice">
    <div class="layui-row">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">渠道名称</label>
                <div class="layui-input-inline">
                    <input type="text" name="channelName" id="channelName" autocomplete="off" class="layui-input" lay-verify="required">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">渠道代码</label>
                <div class="layui-input-inline">
                    <input type="text" name="channelCode" id="channelCode" autocomplete="off" class="layui-input" lay-verify="required">
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">渠道类型</label>
                <div class="layui-input-inline">
                    <layui:simpleDictSelect style='layui-input-inline' type="channel_type" layVerify=""
                                            id="channelType" name="channelType" value=""/>
                </div>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">归属</label>
                <div class="layui-input-inline">
                    <layui:simpleDataSelect name="orgId" value="${isNotEmpty(channelSet)?channelSet.orgId:}" data="${orgList}"
                                            attrId="id" attrName="name" laySearch="true" id="orgId" />
                </div>
            </div>
      </div>
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">分成比例</label>
                <div class="layui-input-inline">
                    <input type="text" name="divideRate" id="divideRate" autocomplete="off" class="layui-input" lay-verify="required|number">
                </div>
         </div>


        </div>
    </div>


    <layui:submitButtons id="addButton" />
</form>
<!--#} -->
<script>
layui.define([ 'form', 'laydate', 'table','channelSetApi'], function(exports) {
    var form = layui.form;
    var channelSetApi = layui.channelSetApi;
    var index = layui.index;
    var isNew = true;
    <!--# if(!(isEmpty(channelJson))){  -->
    isNew = false;
    <!--# } -->
    var view = {
        init:function(){
            Lib.initGenrealForm($("#addForm"),form);
            this.initSubmit();
        },
        initSubmit:function(){
            $("#addButton").click(function(){
                form.on('submit(form)', function(){
                    channelSetApi.saveForm(isNew,$('#addForm'),function(){
                        parent.window.dataReload();
                        Common.info("保存成功");
                        Lib.closeFrame();
                    });
                });
            });

            $("#addButton-cancel").click(function(){
                Lib.closeFrame();
            });
        }

    }
    <!--# if(!(isEmpty(channelJson))){  -->
    var formJson = ${channelJson};
    form.val("editform",formJson);
    $("#channelName").attr("readOnly","true");
    $("#channelCode").attr("readOnly","true");
    $("select").attr("disabled","disabled");
    form.render('select');
    <!--# } -->
    view.init();
});
</script>
